package com.libraryinformation.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.libraryinformation.domain.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Mapper
@Transactional
public interface BacklogDao extends BaseMapper<Backlog> {
    /**
     * 查询所有图书id与图书名
     * @return
     */
    @Select("select id,title,status from backlog WHERE deleted=0; ")
    List<BacklogVO> getAll();

    /**
     * 更新待办事项状态未已删除
     * @param id
     * @return
     */
    @Update("update backlog set deleted = 1 where id = #{id}; ")
    Integer updateByDeleted(Long id);
    /**
     * 更新待办事项状态是否检查
     * @param id
     * @return
     */
    @Update("update backlog set status = #{status} where id = #{id}; ")
    Integer updateByStatus(Integer status,Long id);

    /**
     * 根据id查询图书
     * @param id
     * @return
     */
    @Select("select * from backlog where id = #{id}; ")
    Backlog selectById(String id);
    @Insert("insert into backlog (id, title,status,insertTime,deleted) values (#{id}, #{title}, #{status}, #{insertTime}, 0);")
    Integer insertOrUpdateWeather(Backlog backlog);

    @Select("select id,title,status from backlog WHERE deleted=0  ")
    IPage<BacklogVO> selectAllPage(IPage<Backlog> backlogPage);
}
